9 typedef pair
<int,int> point
;
12 int cache
[1001][1001];
15 int i
= n
.first
, j
= n
.second
;
16 // cout << "n: " << n.first << " " << n.second << endl;
17 if (cache
[i
][j
] != -1){
18 //cout << "Retornando " << cache[n] << endl;
22 if (n
.second
< n
.first
) swap(n
.first
, n
.second
);
24 for (int k
=0; k
<p
.size()-1; ++k
){
25 if (p
[k
]<=n
.first
&& n
.first
<=p
[k
+1] &&
26 p
[k
]<=n
.second
&& n
.second
<=p
[k
+1]){
27 //cout << "Retornando 0" << endl;
28 return cache
[i
][j
] = 0;
33 for (int k
=0; k
<p
.size(); ++k
){
34 if (n
.first
<p
[k
] && p
[k
]<n
.second
){
35 int q
= n
.second
- n
.first
+ f(point(n
.first
, p
[k
])) + f(point(p
[k
], n
.second
));
36 //cout << "q es: " << q << endl;
42 //cout << "min es: " << min << endl;
43 //cout << "Retornando " << min << endl;
44 return cache
[i
][j
] = min
;
50 while (cin
>> l
&& l
> 0){
53 memset(cache
, -1, sizeof(cache
));
57 for (int i
=1; i
<=n
; ++i
){
60 cout
<< "The minimum cutting is " << f(point(0, l
)) << ".\n";